/*
 * Filename CheckProjectServiceImpl.java 2022年03月22日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.service.report;

import com.ehome.core.service.AbstractCrudServiceImpl;
import com.ehome.poct.core.api.dto.CheckStripQry;
import com.ehome.poct.core.api.dto.check.CheckProjectDTO;
import com.ehome.poct.core.api.dto.check.project.EhomeProjectDTO;
import com.ehome.poct.core.api.virtual.CheckProjectService;
import com.ehome.poct.core.repository.TestConfPoctStripTypeRepository;
import com.ehome.poct.core.service.mapping.CheckProjectMapping;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wyc
 * @since 2022/03/22 17:44
 **/
@Service
@AllArgsConstructor
public class CheckProjectServiceImpl extends AbstractCrudServiceImpl<CheckProjectDTO> implements CheckProjectService {
    private final TestConfPoctStripTypeRepository stripTypeRepository;
    private final CheckProjectMapping projectMapping;

    @Override
    public List<EhomeProjectDTO> selectWithType(Integer type) {
        if (type == 0) {
            final var result = projectMapping.toFromGold(stripTypeRepository.selectWithoutUnion());
            result.addAll(projectMapping.toFromBld(this.list(new CheckProjectDTO())));
            return result;
        } else if (type == 1) {

            return projectMapping.toFromGold(stripTypeRepository.selectWithoutUnion());
        }
        return projectMapping.toFromBld(this.list(new CheckProjectDTO().setType(type == 2 ? 1 : 2)));
    }
    @Override
    public List<EhomeProjectDTO> selectWithType( CheckStripQry qry) {
        final var result = projectMapping.toFromGold(stripTypeRepository.selectWithoutUnion(qry));
        result.addAll(projectMapping.toFromBld(this.list(new CheckProjectDTO().setType(1))));
        return result;
    }

    public void disable(Integer confTypeId)
    {

    }
}